package com.example.myapplication.Jobsearch;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;

import com.example.myapplication.R;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class JobsearchActivity extends AppCompatActivity {

    private ImageView img;
    private BottomNavigationView bot;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jobsearch);
        initview();
        but_loak();
        //底部
        botnavigation();
    }

    private void botnavigation() {
        ArchivesFragment archivesFragment = new ArchivesFragment();
        PersonalFragment personalFragment = new PersonalFragment();
        JobFragment jobFragment = new JobFragment();

        getSupportFragmentManager().beginTransaction().replace(R.id.ll, jobFragment).commit();

        bot.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.job:
                        getSupportFragmentManager().beginTransaction().replace(R.id.ll, jobFragment).commit();
                        break;
                    case R.id.archives:
                        getSupportFragmentManager().beginTransaction().replace(R.id.ll, archivesFragment).commit();
                        break;
                    case R.id.personal:
                        getSupportFragmentManager().beginTransaction().replace(R.id.ll, personalFragment).commit();
                        break;

                }
                return true;
            }
        });
    }

    private void but_loak() {
        img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                JobsearchActivity.this.finish();
            }
        });
    }

    private void initview() {
        img = findViewById(R.id.img);
        bot = findViewById(R.id.bot);

    }
}